<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="common.jsp"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!-- 深圳宝田医院 -->
<!DOCTYPE html>
<html>
<head>
<title>呼叫</title>
<script src="${ctx}/jiaohao/amq_jquery_adapter.js"></script>
<script src="${ctx}/jiaohao/amq.js"></script>
<script src="${ctx}/jiaohao/jquery.json-2.2.js"></script>
<script type="text/javascript">
	var allList = [];
	var vac01Arr = [];
//消息推送
$(function () {
	var amq = org.activemq.Amq;  
	amq.init({   
	  uri: 'amq', 
	  logging: true,
	  timeout: 5
	}); 
	var myHandler = function (message) {
		debugger;
		var html;
		$("#msgDiv").empty();
		$("#msgDiv").append(unescape(message.data.replace(/\u/g, "%u")).replace("\\",''));
		var msgData = JSON.parse(message.data);
		var obj = msgData.hJrow;
		var obj2 = msgData.hJrow2;
		if($.inArray(obj.vac01, vac01Arr)<0)
		{
			vac01Arr.push(obj.vac01);
			var count = $("#jiaohaoTr").find("tr").length;
			if(count%2==1)
			{
				html = "";
				html += '<tr class="trline01">';
				//html += '<td>请</td>';
				html += '<td>'+(obj["vad21"]?obj["vad21"]:'-')+'</td>';
				html += '<td>'+obj["vaa05"]+'</td>';
				html += '<td>到</td>';
				html += '<td>'+obj["bck03"]+'</td>';
				html += '<td>'+(obj["bas02a"]?obj["bas02a"]:'-')+'</td>';
				html += '<td>就诊</td>';
				html += '<td>'+(obj["bce03a"]?obj["bce03a"]:'-')+'</td>';
				//html += '<td>下一位</td>';
				//html += '<td>'+(obj2?obj2["vad21"]:'-')+'</td>';
				//html += '<td>'+(obj2?obj2["vaa05"]:'-')+'</td>';
				//html += '<td>准备</td>';
				html += '</tr>';
			}
			else
			{
				html = "";
				html += '<tr class="trline02">';
				//html += '<td>请</td>';
				html += '<td>'+(obj["vad21"]?obj["vad21"]:'-')+'</td>';
				html += '<td>'+obj["vaa05"]+'</td>';
				html += '<td>到</td>';
				html += '<td>'+obj["bck03"]+'</td>';
				html += '<td>'+(obj["bas02a"]?obj["bas02a"]:'-')+'</td>';
				html += '<td>就诊</td>';
				html += '<td>'+(obj["bce03a"]?obj["bce03a"]:'-')+'</td>';
				//html += '<td>下一位</td>';
				//html += '<td>'+(obj2?obj2["vad21"]:'-')+'</td>';
				//html += '<td>'+(obj2?obj2["vaa05"]:'-')+'</td>';
				//html += '<td>准备</td>';
				html += '</tr>';
			}
		}
		if(count>5)
		{
			$("#jiaohaoTr").find("tr").last().remove();
			vac01Arr.shift();
		}
		$("#jiaohaoTr").prepend(html);
	}
	debugger;
	var topic = $("#topic").val();
	amq.addListener("smeguangdong","topic://"+topic,myHandler);
});

</script>
<link href="${ctx}/jiaohao/css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<input type="hidden" id="topic" value="<%=request.getParameter("topic")%>"/>
	<div id="msgDiv" style="display: none;"></div>
	<div id="user" data-info=""></div>
	
    <div class="header">
      <div class="topleft">
      </div> 
         <div class="topcenter">
        <span><%=request.getParameter("name")%></span>
      </div> 
      
      <div class="topright">
        <span></span>
      </div>       
    </div>
    <!--顶部的结束-->
     <div class="formbody">
        <div class="maininfo">
           <table class="imgtable">
            <thead>
            <tr>
                <!-- <th width="1%" height="100"></th> -->
                <th width="2%">号数</th>
                <th width="2%">姓名</th>
                <th width="2%"></th>
                <th width="5%">科室</th>
                <th width="5%">诊室</th>
                <th width="2%">状态</th>
                <th width="2%">医生</th>
                <!-- <th width="2%"></th>
                <th width="2%">号数</th>
                <th width="2%">姓名</th>
                <th width="2%"></th> -->
            </tr>
            </thead>
            <tbody id="jiaohaoTr"></tbody>
            </table>
        </div>
      </div>
   <!--中间区域结束-->
   <div class="footer">
     请在候诊厅等待就诊，保持安静，不要走开，祝您早日康复
   </div>
